<?php

class Halls_DeleteAction extends SrsHallsBaseAction
{
	public function getCredentials()
	{
		return 'halls.delete';
	}

	public function executeRead(AgaviRequestDataHolder $rd)
	{
		$hall = Doctrine_Query::create()
		        ->from('Hall')
			      ->where('id=?', $rd->getParameter('id'))
						->fetchOne();

		if (!$hall instanceof Hall) return $this->forward404();

		$this->setAttribute('hall', $hall);

		return 'Input';
	}

	public function executeWrite(AgaviRequestDataHolder $rd)
	{
		$deleted = Doctrine_Query::create()
		           ->delete('Hall')
		           ->where('id=?', $rd->getParameter('id'))
						   ->execute();

		return $deleted ? 'Success' : 'Error';
	}
}